public class Company {
    //公司名称，注册地址，电话，经营范围
    String companyName, address, phoneNumber, manage;
    People[] people = new People[100];
    int count = 0;

    public void add(People pe) {
        if (count >= people.length) {
            System.out.println("员工已满");
            return;
        }
        people[count] = new People();
        people[count].name = pe.name;
        people[count].money = pe.money;
        count++;
        System.out.println("添加成功");
    }

    public void show() {
        for (int i = 0; i < count; i++) {
            System.out.print("员工的姓名：" + people[i].name + " " + "员工的薪水：" + people[i].money);
            System.out.println();
        }
    }

    public boolean delete(String name) {
        for (int i = 0; i < count; i++) {
            if (name.equals(people[i].name)) {
                for (int j = i; j < count - 1; j++) {
                    people[j] = people[j + 1];
                }
                people[count - 1] = null;
                count--;
                return true;
            }
        }
        return false;
    }

    public int statistics() {
        return count;
    }

    public double findSalary() {
        if (count != 0) {
            double max = people[0].money;
            int j = 0;
            for (int i = 1; i < count; i++) {
                if (max < people[i].money) {
                    max = people[i].money;
                    j = i;
                }
            }
            return people[j].money;
        } else {
            return -1;
        }
    }

    public void sortSalary() {
        for (int i = 0; i < count - 1; i++) {
            for (int j = 0; j < count - i - 1; j++) {
                if (people[j].money < people[j + 1].money) {
                    People temp = people[j];
                    people[j] = people[j + 1];
                    people[j + 1] = temp;
                }
            }
        }
        this.show();
    }

    //1）求所有员工的平均工资
    public double avg() {
        double sum = 0;
        if (count != 0) {
            for (int i = 0; i < count; i++) {
                sum += people[i].money;
            }
            return sum / count;
        } else return -1;
    }

    //2）给所有员工涨工资
    public void raise() {
        if (count != 0) {
            for (int i = 0; i < count; i++) {
                if (people[i].money < 5000) {
                    people[i].money += 500;
                } else people[i].money += 100;
            }
            System.out.println("涨薪成功");
            this.show();
        } else System.out.println("无事发生");
    }
}